/*
* Terminal
*/
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "stm32f4xx.h"
#include "stm32f4_discovery.h"
#include "stm32f4xx_usart.h"
#include "ds130x.h"

#ifndef _TERMINAL_H_
#define _TERMINAL_H_

#ifdef __cplusplus
 extern "C" {
#endif /* __cplusplus */

#define PORT_USART			USART2
#define PORT_GPIO_USART		GPIOA
#define GPIO_AF_TX			GPIO_AF_USART2
#define GPIO_AF_RX			GPIO_AF_USART2
#define GPIO_PinSource_TX	GPIO_PinSource2
#define GPIO_PinSource_RX	GPIO_PinSource3

#define LENGTH_MAX_COMMAND	((uint8_t)6)

typedef struct {
	uint8_t	*pu8_Command;
	uint8_t (*Exe_Func)(uint8_t *pu8_Command, uint8_t *pu8_Data);
	uint8_t	*pu8_Comment;
} CtrlPeriph;



uint8_t Terminal_Init(void);
void Send_Char(uint8_t u8_Char);
void Send_String(uint8_t *String);
uint8_t Receive_Char(void);
void Terminal_Command_Data(uint8_t *pu8_InBuffer, uint8_t *pu8_Command, uint8_t *pu8_Data);
void Terminal_Print_Help(uint8_t *pu8_Command, uint8_t *ChuThich);
uint8_t Terminal_Command_Ver(uint8_t *pu8_Command, uint8_t *pu8_Data);
uint8_t Terminal_Command_Help(uint8_t *pu8_Command, uint8_t *pu8_Data);
uint8_t Terminal_Peripheral_Led(uint8_t *pu8_Command, uint8_t *pu8_Data);
uint8_t Terminal_Time_Sec(uint8_t *pu8_Command, uint8_t *pu8_Data);
uint8_t Terminal_Time_Min(uint8_t *pu8_Command, uint8_t *pu8_Data);
uint8_t Terminal_Time_Hour(uint8_t *pu8_Command, uint8_t *pu8_Data);
uint8_t Terminal_Time_Date(uint8_t *pu8_Command, uint8_t *pu8_Data);
uint8_t Terminal_Time_Month(uint8_t *pu8_Command, uint8_t *pu8_Data);
uint8_t Terminal_Time_Day(uint8_t *pu8_Command, uint8_t *pu8_Data);
uint8_t Terminal_Time_Year(uint8_t *pu8_Command, uint8_t *pu8_Data);
uint8_t Terminal_Set_Time(uint8_t *pu8_Command, uint8_t *pu8_Data);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* _TERMINAL_H_ */
